<%@ page import="java.util.ArrayList" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2024/12/2
  Time: 8:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<form action="sj.jsp" method="post" accept-charset="UTF-8">
    请输入书本：<input name="book" type="text">
    <input type="submit" value="添加到购物车">
</form>
<HR>
<%
    ArrayList books =(ArrayList)session.getAttribute("books");
    if (books == null){
        books = new ArrayList();
        session.setAttribute("books",books);
    }
    String book = request.getParameter("book");
    if (book != null) {
        book = new String(book.getBytes("ISO-8859-1"),"UTF-8");
        books.add(book);
    }
%>
<a href="gwc.jsp">查看购物车</a>
</body>
</html>
